//
//  NewPerSonImageInfoViewController.m
//  wangzhe
//
//  Created by 李 佳伟 on 2018/4/2.
//  Copyright © 2018年 李 佳伟. All rights reserved.
//

#import "NewPerSonImageInfoViewController.h"
#import "JTCSM.h"
static CGFloat idcardBili = 0.641026;
static CGFloat shouchiBili = 1.153846;
static CGFloat space = 20;
static CGFloat headerHeight = 50;
@interface NewPerSonImageInfoViewController ()<UINavigationControllerDelegate>
{
    CGFloat imagewidth;
    CGFloat imageHeight;
}
@property (nonatomic,strong) UIImageView *IDCardZhengImageV;
@property (nonatomic,strong) UIImageView *IDCardFanImageV;
@property (nonatomic,strong) UIImageView *shouchiIDcardImageV;
@property (nonatomic,strong) UIImageView *bankImageV;
@property (nonatomic,strong) UIImageView *otherImageV;
@end

@implementation NewPerSonImageInfoViewController
- (void)gotBack{
    [self.navigationController popViewControllerAnimated:YES];
}
// 将要显示控制器
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
    // 判断要显示的控制器是否是自己
//    BOOL isShowHomePage = [viewController isKindOfClass:[self class]];
    [self.navigationController setNavigationBarHidden:NO animated:YES];
}
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:YES];
    self.navigationController.delegate = self;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    [self.view setBackgroundColor:[UIColor whiteColor]];
    [df isRemoveTarbar:YES];
    leftBarButtonItems_rightBarButtonItems *leftbtn = KCUSTOMNAVIGSTION_ALLOC;
    self.navigationItem.leftBarButtonItem = [leftbtn setBarButtonItemsImageName:@"fanhui.png" frame:KLeftBarButtonItemFrame_image target:self SEL:@selector(gotBack)];
    
    UIScrollView *backScrollview = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, KCONTROLLERWith, KCONTROLLERHeight)];
    backScrollview.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:backScrollview];
    
    [backScrollview addSubview:[self LayoutHeaderWithTop:0 text:@"为保障顺利通过审核，请上传真实附件信息。"]];
    imagewidth = (KCONTROLLERWith/2-space-space/2);
    imageHeight = imagewidth*idcardBili;
    
    self.IDCardZhengImageV = [[UIImageView alloc]initWithFrame:CGRectMake(space, headerHeight+space, imagewidth, imageHeight)];
    self.IDCardZhengImageV.image = [UIImage imageNamed:@"身份证正面.png"];
    [backScrollview addSubview:self.IDCardZhengImageV];
    [self layoutSpringViewWithText:@"上传身份证正面" superView:self.IDCardZhengImageV];

    self.IDCardFanImageV = [[UIImageView alloc]initWithFrame:CGRectMake(KVIEW_X(self.IDCardZhengImageV)+space, headerHeight+space, imagewidth, imageHeight)];
    self.IDCardFanImageV.image = [UIImage imageNamed:@"身份证反面.png"];
    [backScrollview addSubview:self.IDCardFanImageV];
    [self layoutSpringViewWithText:@"上传身份证反面" superView:self.IDCardFanImageV];
    
    UIImageView *shoushiImageV = [[UIImageView alloc]initWithFrame:CGRectMake(space, KVIEW_Y(self.IDCardZhengImageV)+space/2, imagewidth, imagewidth*shouchiBili)];
    shoushiImageV.image = [UIImage imageNamed:@"手持身份证.png"];
    [backScrollview addSubview:shoushiImageV];
    
    
    self.shouchiIDcardImageV = [[UIImageView alloc]initWithFrame:CGRectMake(KVIEW_X(self.IDCardZhengImageV)+space, KVIEW_Y(self.IDCardZhengImageV)+space/2, imagewidth, imagewidth*shouchiBili)];
    self.shouchiIDcardImageV.image = [UIImage imageNamed:@"手持身份证-上传.png"];
    [backScrollview addSubview:self.shouchiIDcardImageV];
    [self layoutSpringViewWithText:@"手持身份证照片" superView:self.shouchiIDcardImageV];
    
    
   UIView *lineview =[df newlineViewWithHeightofTop:KVIEW_Y(self.shouchiIDcardImageV)+space*3/2 superView:backScrollview spacing:0 color:RGBACOLOR(241, 241, 241, 1) lineHeight:10];
    
    
    self.bankImageV = [[UIImageView alloc]initWithFrame:CGRectMake(space, KVIEW_Y(lineview)+space, imagewidth, imageHeight)];
    self.bankImageV.image = [UIImage imageNamed:@"银行卡正面.png"];
    [backScrollview addSubview:self.bankImageV];
    [self layoutSpringViewWithText:@"上传银行卡正面" superView:self.bankImageV];
    
    
    
    self.otherImageV = [[UIImageView alloc]initWithFrame:CGRectMake(KVIEW_X(self.IDCardZhengImageV)+space, KVIEW_Y(lineview)+space, imagewidth, imageHeight)];
    self.otherImageV.image = [UIImage imageNamed:@"其他资料.png"];
    [backScrollview addSubview:self.otherImageV];
    [self layoutSpringViewWithText:@"其他资料（可选）" superView:self.otherImageV];
    
    
    [backScrollview setContentSize:CGSizeMake(KCONTROLLERWith, KVIEW_Y(self.otherImageV)+space)];
    
}


- (UIView *)LayoutHeaderWithTop:(CGFloat)top text:(NSString *)text{
    UIView *infoView = [[UIView alloc]initWithFrame:CGRectMake(0, top, KCONTROLLERWith, headerHeight)];
    infoView.backgroundColor = RGBACOLOR(241, 241, 241, 1);
    infoView.userInteractionEnabled = YES;
    
    NSString *infoStr = text;
    float infoSize = 12;
    CGRect inforect = [df labelHeightWithContent:infoStr height:headerHeight font:infoSize];
    UIImageView *infoImagev = [[UIImageView alloc]initWithFrame:CGRectMake(space, (headerHeight-inforect.size.height)/2, inforect.size.height, inforect.size.height)];
    infoImagev.image = [UIImage imageNamed:@"tanhao.png"];
    [infoView addSubview:infoImagev];
    
    UILabel *infolabel = [UILabel initWithFrame:CGRectMake(KVIEW_X(infoImagev)+5, (headerHeight-inforect.size.height)/2, KCONTROLLERWith, inforect.size.height) text:infoStr font:infoSize textAlignment:NSTextAlignmentLeft texcolor:RGBACOLOR(51, 51, 51, 1) backgroundColor:nil];
    [infoView addSubview:infolabel];
    
    return infoView;
}
- (void )layoutSpringViewWithText:(NSString *)text superView:(UIView *)superview{
    UIView *springView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, imagewidth, (superview == self.shouchiIDcardImageV)?imagewidth*shouchiBili:imageHeight)];
    springView.backgroundColor = [UIColor clearColor];
    springView.userInteractionEnabled = YES;
    
    CGFloat imagesize = 40;
    CGFloat labelHeight = 30;
    CGFloat changeheight = 2;
    CGFloat top = (springView.LC_height-imagesize-labelHeight-changeheight)/2;
    UIImageView *imagev = [[UIImageView alloc]initWithFrame:CGRectMake((imagewidth-imagesize)/2, top, imagesize, imagesize)];
    imagev.image = [UIImage imageNamed:@"照片image.png"];
    imagev.userInteractionEnabled = YES;
    [springView addSubview:imagev];
    
    UILabel *label = [UILabel initWithFrame:CGRectMake(0, KVIEW_Y(imagev)+changeheight, imagewidth, labelHeight) text:text font:12 textAlignment:NSTextAlignmentCenter texcolor:[df colorWithHexString:@"666666" alpha:1] backgroundColor:nil];
    label.userInteractionEnabled = YES;
    [springView addSubview:label];
    [superview addSubview:springView];
    [superview bringSubviewToFront:springView];
    [superview setUserInteractionEnabled:YES];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
